<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">
  <head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2023. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">

    <title>Java Build Path</title>
    <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
  </head>

  <body>
    <h1>Java Build Path</h1>

    <p>The options in this page indicate the build path settings for a Java project. You can reach this page through the project properties (Project &gt; Properties &gt; Java Build Path) from the context menu on a created project or the <a href="ref-menu-file.htm">File
      menu</a> of the workbench.</p>

    <p>The build class path is a list of paths visible to the compiler when building the project.</p>

    <p>For projects targeting Java 9 or greater, entries on the <a href="#projects">Projects</a> and <a href="#libraries">Libraries</a> tabs
     can be placed either on the traditional Classpath or on the Modulepath.
     Entries on the Modulepath are interpreted as <strong>modules</strong> according to the 
     <a href="http://openjdk.java.net/projects/jigsaw/spec">Java Platform Module System</a>.
     For these, further details can be edited via <a href="propertypages/ref-properties-buildpath-modularity.htm">Modularity Details</a>.
    </p>
    
    <p>This property page consists of the following tabs:</p>
    <ul>
    <li><a href="#source">Source tab</a></li>
    <li><a href="#projects">Projects tab</a></li>
    <li><a href="#libraries">Libraries tab</a></li>
    <li><a href="#order-and-export">Order and Export tab</a></li>
    <li><a href="#module-dependencies">Module Dependencies tab</a></li>
    </ul>

    <h2 id="source">Source tab</h2>

    <p>Source folders are top-level folders in the project hierarchy. They are the root of packages containing .java files. 
    The compiler will translate the contained files to .class files that will be written to the output folder.</p>
<p>Source folders allow to structure the project, for example to separate 
test from the application in two source folders. Within a source folder, a more detailed structuring can be achieved by using packages.</p> 
<p>Each source folder can define an exclusion filter to specify which 
resources inside the folder should not be visible to the compiler.</p>
<p>Resources existing in source folders are copied to the output folder unless the setting in the <a href="preferences/java/compiler/ref-preferences-building.htm">Java &gt; Compiler &gt; Building</a> preference
    page specifies that the resource is filtered. The output folder is defined per project except if a source folder specifies its own output folder.</p>

<table border="1" cellspacing="0" cellpadding="5" summary="Source folder options" width="600">
	<caption>Source folder options:<br>
	</caption>

	<tbody>
		<tr>
			<th>Option</th>

			<th>Description</th>
		</tr>

		<tr>
			<td align="left" valign="top" width="20%">Add Folder</td>

			<td align="left" valign="top">Creates a new folder to contain source</td>
		</tr>
		<tr>
			<td align="left" valign="top" width="20%">Link Source</td>

			<td align="left" valign="top">Creates a new folder that links to an location outside of the workspace</td>
		</tr>
		<tr>
			<td align="left" valign="top">Edit or Toggle</td>

			<td align="left" valign="top">Allows to modify the currently selected
			source folder or source folder attribute.</td>
		</tr>

		<tr>
			<td>Remove</td>

			<td>Removes the selected folders from the class path. This does not
			delete the folders nor their contents.</td>
		</tr>
		<tr>
			<td>Allow output folder per source folder</td>
			<td>Shows/Hides the 'output folder' attribute of the source folders</td>
		</tr>
		
	</tbody>
</table>
<br>
<table border="1" cellspacing="0" cellpadding="5" summary="Source folder attributes" width="600">
	<caption>Source folder attributes:<br>
	</caption>

	<tbody>
		<tr>
			<th>Attribute</th>

			<th>Description</th>
		</tr>

		<tr>
			<td align="left" valign="top" width="20%">Exclusion filter</td>

			<td align="left" valign="top">Selects which resources are not visible to the compiler. For details see <a href="../concepts/concept-inclusion-exclusion-patterns.htm">Inclusion and exclusion patterns</a>.</td>
		</tr>

		<tr>
			<td align="left" valign="top">Output folder</td>

			<td align="left" valign="top">Only available when <b>Allow output
			folder per source folder</b> is checked. Defines a source folder specific output location. If not set the project's default output folder is used.</td>
		</tr>
		<tr>
			<td align="left" valign="top">Native library location</td>
			<td align="left" valign="top">Defines the folder that contains the native libraries
			  (for example 'dll' or 'o' files) required at runtime by the sources in the source folder.
			</td>
		</tr>

		<tr>
			<td align="left" valign="top">Ignore optional compile problems</td>
			<td align="left" valign="top">When set to 'Yes', all optional problems will not be reported by the compiler.</td>
		</tr>

		<tr>
			<td align="left" valign="top">Contains test sources</td>
			<td align="left" valign="top">When set to 'Yes', the sources in the folder are assumed to be test code, 
			otherwise main code. When compiling main code, only other main code (from the current project or from other projects on the build path) is visible and only dependencies 
			that are not configured to be visible for test code only. When compiling test code, all code on build path 
			is visible. When compiling test code with Java 9, the unnamed module is assumed to be readable 
			by the current module, so test dependencies that should not be mentioned in the <code>module-info.java</code> are accessible if they are put 
			on the classpath.</td>
		</tr>
	</tbody>
</table>

    <p>At the bottom of this page, the <b>Default output folder</b> field allows you to enter a path to a folder path where the compilation output for this
    project will reside. The default output is used for source folders that do not specify an own output folder. Use <b>Browse</b> to select an existing location from the current project.</p>
    
    <h2 id="projects">Projects tab</h2>

    <p>In the <b>Required projects on the build path</b> list, you can add project dependencies by selecting other workbench
    projects to add to the build path for this new project.</p>

    <p>Adding a required project indirectly adds all its classpath entries marked as 'exported'. Setting a classpath entry as exported is done in the Order and Export tab.</p>

    <p>The projects selected here are automatically added to the referenced projects list. The referenced project list is used to determine the build order. A project is always
    build after all its referenced projects are built.</p>
    
    <table border="1" cellspacing="0" cellpadding= "5" summary="Project entry options" width="600">

	<tbody>
		<tr>
			<th>Action</th>

			<th>Description</th>
		</tr>

		<tr>
			<td align="left" valign="middle" width="20%">Add</td>

			<td align="left" valign="top">Add another project in the workspace to the build path of this project.</td>
		</tr>
		
		<tr>
			<td align="left" valign="middle" width="20%">Edit or Toggle</td>

			<td align="left" valign="top">Edit the classpath attribute of a required project.</td>
		</tr>
		
		<tr>
			<td align="left" valign="middle" width="20%">Remove</td>

			<td align="left" valign="top">Removes the selected required projects from the list.</td>
		</tr>
		
	</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="5" summary="Project entry attributes"
	width="600">
	<caption>Project entry attributes:<br>
	</caption>

	<tbody>
		<tr>
			<th>Attribute</th>

			<th>Description</th>
		</tr>
		
		<tr>
			<td align="left" valign="top">Native library location</td>

			<td align="left" valign="top">Specifies where native library required for the project to operate can be found.</td>
		</tr>

		<tr>
			<td align="left" valign="top">Is&nbsp;modular / Is&nbsp;not&nbsp;modular</td>

			<td align="left" valign="top">Specifies whether the project should be treated as a module.
			Double-click to edit <a href="propertypages/ref-properties-buildpath-modularity.htm">Modularity Details</a>.</td>
		</tr>

		<tr>
			<td align="left" valign="top">Access rules</td>

			<td align="left" valign="top">Specifies access rules for project contained in the library. This allows to hide content of a project.</td>
		</tr>
		<tr>
			<td align="left" valign="top">Visible only for test sources</td>
			<td align="left" valign="top">When set to 'Yes', the code reachable via the referenced project is only accessible when sources in sources folder marked to contain test code are compiled.</td>
		</tr>
		<tr>
			<td align="left" valign="top">Without test code</td>
			<td align="left" valign="top">When this is set to 'Yes', test code from the referenced project is not visible when compiling test code in the current project.</td>
		</tr>
	</tbody>
</table>

    <h2 id="libraries">Libraries tab</h2>

    <p>On this page, you can add libraries to the build path.</p>
    <p>By default, the library list contains an entry representing the Java runtime library.  This entry points to the JRE
    selected as the default JRE. The default JRE is configured in the <a href="preferences/java/debug/ref-installed_jres.htm">Java &gt; Debug &gt; Installed JREs</a> preferences page.</p>

    <table border="1" cellspacing="0" cellpadding= "5" summary="Libraries tab options" width="600">
      <caption>
        Libraries tab options:<br>
      </caption>

      <tbody>
        <tr>
          <th width="20%">Option</th>

          <th>Description</th>
        </tr>

        <tr>
          <td align="left" valign="top">Add JARs</td>

          <td align="left" valign="top">Allows you to navigate the workbench hierarchy and select JAR files to add to the build path.</td>
        </tr>

        <tr>
          <td align="left" valign="top">Add External JARs</td>

          <td align="left" valign="top">Allows you to navigate the file system (outside the workbench) and select JAR files to add to the build path.</td>
        </tr>

        <tr>
          <td align="left" valign="top">Add Variable</td>

          <td align="left" valign="top">Allows you to add classpath variables to the build path. Classpath variables are an indirection to JARs with the benefit of avoiding local
          file system paths in a classpath. This is needed when projects are shared in a team.<br>
           Variables can be created and edited in the <a href="preferences/java/buildpath/ref-preferences-classpath-variables.htm">Java &gt; Build Path &gt; Classpath Variables</a> preference page.</td>
        </tr>

        <tr>
          <td>Add Library</td>

          <td>Allows to add a predefined libraries like the JRE System Library. Such libraries can stand for an arbitrary number of entries (visible as children node of the library node)</td>
        </tr>

        <tr>
          <td>Add Class Folder</td>

          <td>Allows to navigate the workbench hierarchy and select a class folder for the build path. The selection dialog also allows you to create a new folder.</td>
        </tr>

        <tr>
          <td>Add External Class Folder</td>

          <td>Allows to navigate the file system (outside the workbench) and select a class folder for the build path. The selection dialog also allows you to create a new folder.</td>
        </tr>

        <tr>
          <td align="left" valign="top">Edit or Toggle</td>

          <td align="left" valign="top">Allows you to modify the currently selected library entry or entry attribute</td>
        </tr>

        <tr>
          <td align="left" valign="top">Remove</td>

          <td align="left" valign="top">Removes the selected element from the build path. This does not delete the resource.</td>
        </tr>
        
        <tr>
          <td align="left" valign="top">Migrate JAR File</td>

          <td align="left" valign="top">Migrate a JAR on the build path to a newer version. If the newer version contains refactoring scripts
          the refactoring stored in the script will be executed.</td>
        </tr>
      </tbody>
    </table>

    <p>&nbsp;Libraries have the following attributes (presented as library entry children nodes):</p>

<table border="1" cellspacing="0" cellpadding="5" summary="Library entry attributes"
	width="600">
	<caption>Library entry attributes:<br>
	</caption>

	<tbody>
		<tr>
			<th>Attribute</th>

			<th>Description</th>
		</tr>

		<tr>
			<td align="left" valign="top">Source attachment</td>

			<td align="left" valign="top">Specifies where the library's source can be found.</td>
		</tr>

		<tr>
			<td align="left" valign="top" width="20%">Javadoc location</td>

			<td align="left" valign="top">Specifies where the library's Javadoc documentation can be found. If specified you can use <b>Shift+F2</b> on an element of this library to open its documentation.</td>
		</tr>

		<tr>
			<td align="left" valign="top" width="20%">External annotations</td>

			<td align="left" valign="top">Specifies where <a href="../tasks/task-using_external_null_annotations.htm">external annotations</a> for the library can be found.
				If specified these annotations will be considered by JDT for its static null analysis.</td>
		</tr>
		
		<tr>
			<td align="left" valign="top">Native library location</td>

			<td align="left" valign="top">Specifies where native library required for the library to operate can be found.</td>
		</tr>
		
		<tr>
			<td align="left" valign="top">Is&nbsp;modular / Is&nbsp;not&nbsp;modular</td>

			<td align="left" valign="top">Specifies whether the library should be treated as a module (or several modules).
			 Double-click to edit <a href="propertypages/ref-properties-buildpath-modularity.htm">Modularity Details</a>.</td>
		</tr>
		
		<tr>
			<td align="left" valign="top">Access rules</td>

			<td align="left" valign="top">Specifies access rules for resources contained in the library. This allows to hide content of a library.</td>
		</tr>
		<tr>
			<td align="left" valign="top">Visible only for test sources</td>
			<td align="left" valign="top">When set to 'Yes', the code in the referenced library is only accessible when sources in source folders marked to contain test code are compiled.</td>
		</tr>
	</tbody>
</table>

<h2 id="order-and-export">Order and Export tab</h2>

    <p>In the <b>Build class path order</b> list, you can click the <b>Up</b> and <b>Down</b> buttons to move the selected path entry up or down in the build path order for this new project.</p>

    <p>Checked list entries are marked as exported. Exported entries are visible to projects that require the project. Use the <b>Select
    All</b> and <b>Deselect All</b> to change the checked state of all entries. Source folders are always exported,
    and can not be deselected.</p>
    
<h2 id="module-dependencies">Module Dependencies tab</h2>
	<p>For projects targeting Java 9 or greater this page visualizes module-related aspects of all dependencies of the current project.
	At the left the <b>All Modules</b> list shows all modules that are considered when building the current projects.
	At the right <b>Details</b> of a selected module are shown, along with buttons to modify these details.</p>
	
	<p>The <b>All Modules</b> list uses the following icon decorations to distinguish different kinds of modules:</p>
	<table border="1" cellspacing="0" cellpadding="5" summary="Module decorations">
	<tbody>
	<tr><th>Decorated Icon</th><th>Meaning</th></tr>
	<tr><td><img src="../images/org.eclipse.jdt.ui/combined/focus_module.svg" alt="focus module" width="30"></td>
		<td>The <b>focus</b> module, i.e., the module implemented by the current project.
		This module will always be shown at the top of the list, followed by other modules
		in alphabetical order.</td>
	<tr><td><img src="../images/org.eclipse.jdt.ui/combined/system_module.svg" alt="system module" width="30"></td>
		<td>A <b>system</b> module, i.e., a module provided by the Java System Library.</td>
	<tr><td><img src="../images/org.eclipse.jdt.ui/combined/auto_module.svg" alt="automatic module" width="30"></td>
		<td>An <b>automatic</b> module, i.e., a module that is not declared using <code>module-info.java</code>,
		but inferred from information like the file name of a jar archive, or an attribute in <code>MANIFEST.MF</code>
		and the list of contained, non-empty packages.</td>
	</tbody>
	</table>
	<p>Operations offered for the All Modules list:</p>
	<ul>
	<li>You may remove one or more System modules by selecting the respective modules and clicking the <b>Remove</b>
		button at the right. Note, that other modules need to be removed from the build path on the respective
		Projects or Libraries tab.</li>
	<li>If the current project lacks file <code>module-info.java</code>, i.e., types in the project are associated
		with the "unnamed module", then by default only a subset of System modules is considered. In this case
		you can pull in more System modules by clicking the <b>Add System Module...</b> button.</li>
	</ul>
	<p><em>Modules that have just been added to the Modulepath on the corresponding tab of this page,
		will not be visible in this list immediately.
		In this case you need to click <b>Apply</b> to update the All Modules list.</em></p>
	
	<p>The <b>Details</b> tree has two root nodes:</p>
	<ul>
	<li>under the top node <b>Declared details of <i>modulename</i></b>
	you can find those details that are declared in the select module's description, namely representations
	of all <b>requires</b>, <b>exports</b> and <b>opens</b> declarations.</li>
	<li>under <b>Configured details</b> additional properties of the selected module can be configured.</li>
	</ul>
		
	<p>The elements in this part of the page are marked with one of the following decorated icons:</p>
	<table border="1" cellspacing="0" cellpadding="5" summary="Detail icons and decorations">
	<tbody>
	<tr><th>Decorated Icon</th><th>Meaning</th></tr>
	<tr><td><img src="../images/org.eclipse.jdt.ui/combined/reads_module.svg" alt="reads module" width="30"></td>
		<td>A module which the selected module <b>reads</b>. This corresponds to a <b>requires</b> declaration.</td>
	<tr><td><img src="../images/org.eclipse.jdt.ui/combined/exports_packages.svg" alt="exports package" width="30"></td>
		<td>A package which the selected module <b>exports</b> to other modules, possibly qualified with a list
		of modules to which the package is <i>exclusively</i> exported.
		This corresponds to an <b>exports</b> or <b>exports _ to</b> declaration.</td>
	<tr><td><img src="../images/org.eclipse.jdt.ui/combined/opens_package.svg" alt="opens package" width="30"></td>
		<td>A package which the selected module <b>opens</b> to other modules (for reflection),
		possibly qualified with a list of modules to which the package is <i>exclusively</i> opened.
		This corresponds to an <b>opens</b> or <b>opens _ to</b> declaration.</td>
	<tr><td><img src="../images/org.eclipse.jdt.ui/combined/patch_project.svg" alt="patches module" width="30"></td>
		<td>A project (or source folder) that <b>patches</b> the selected module, i.e.,
		all types in that project (or source folder) will be <i>associated with</i>,
		and compiled as part of	the selected module.</td>
	</tbody>
	</table>
	
	<p>Operations offered for the Details tree, provided that a module has been selected in the All Modules list:</p>
	<ul>
	<li>By clicking <b>Read Module...</b> you can create a new dependency from the select module to one or more other modules.</li>
	<li>By clicking <b>Expose Package...</b> you can define that the selected module <b>exports</b> or 
		<b>opens</b> one of its packages. The dialog that opens when you click this button supports code completion
		for selecting a package and also has a field where a list of target modules can be specified.</li>
	<li>By double clicking an existing <b>exports</b> or <b>opens</b> node you can edit its details.
		The same can also be done by clicking the <b>Edit...</b> button.</li>
	<li>By clicking <b>Patch with...</b> you can select a project or source folder for patching the selected module.</li>
	<li>Any node under the <b>Configured details</b> node can be removed by clicking <b>Remove</b></li>
	<li>Everything that has been configured in this tab can be translated into a set of command line options
		as specified by the Java Platform Module System (JPMS).
		To do so click the <b>Show JPMS Options...</b> button.<br> 
		These options could be used for invoking a compiler from the command line,
		or as runtime options when launching the program, to ensure that the JVM
		will see the same module graph that has been configured here.</li>
	</ul>
	
    <h3 class="related">Related concepts</h3>
     <a href="../concepts/concept-build-classpath.htm">Build classpath</a><br>
     <a href="../concepts/concept-classpath-variables.htm">Classpath variables</a><br>
     <a href="../concepts/concept-inclusion-exclusion-patterns.htm">Inclusion and exclusion patterns</a>
    <h3 class="related">Related references</h3>
     <a href="../reference/propertypages/ref-properties-buildpath-modularity.htm">Modularity details <i>(deprecated)</i></a><br>
     <a href="../reference/ref-jdt-faq.htm">Frequently asked questions on JDT</a><br>
     <a href="../reference/preferences/java/buildpath/ref-preferences-classpath-variables.htm">Classpath variables preferences</a><br>
     <a href="../reference/preferences/java/ref-preferences-build-path.htm">Build path preferences</a><br>
     <a href="../reference/preferences/java/ref-preferences-compiler.htm">Compiler preferences</a>
  </body>
</html>

